﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace SharedLib.Engine
{
    public class Tile
    {
        private Vector2 _position;
        public Vector2 Position
        {
            get { return _position; }
            set { _position = value; }
        }

        private byte _value;
        public byte Value
        {
            get { return _value; }
            set { _value = value; }
        }

        public Color Couleur { get; set; }

        public Tile()
        {
            Couleur = Color.White;
        }

        private static Texture2D tileTexture;
        public static void LoadContent(ContentManager Content)
        {
            tileTexture = Content.Load<Texture2D>("Texture/blocTiles");
        }

        public static Texture2D getTexture()
        {
            return Tile.tileTexture;
        }

        public static Rectangle getTileRectangle(byte value)
        {
            int row = value / Constants.TILESHEET_WIDTH;
            int column = value - (row * Constants.TILESHEET_WIDTH);

            Rectangle display = new Rectangle(column * Constants.TILE_SIZE, row * Constants.TILE_SIZE, Constants.TILE_SIZE, Constants.TILE_SIZE);

            return display;
        }
    }
}
